package com.dylan.springdatajpa.web.controller;

import com.dylan.springdatajpa.persistence.entity.User;
import com.dylan.springdatajpa.service.user.UserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户控制器
 *
 * @author zhangshaojian
 * @date 2022/7/29 9:30
 */
@Slf4j
@RestController
@RequestMapping("user")
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    @GetMapping
    public List<User> findAll() {
        return userService.findAll();
    }

    @GetMapping("saync")
    public void asyncTransactionTest() {
        log.info("当前线程名称：{}", Thread.currentThread().getName());
        userService.asyncTransactionTest();
    }


}
